import xlwt
import random

workbook = xlwt.Workbook(encoding='utf-8')
sheet = workbook.add_sheet("成绩表")
# 添加表头
fields = ['数学','英语','语文']
for index,field in enumerate(fields):
    sheet.write(0,index,field)

# 随机的添加成绩
for row in range(1,10):
    for col in range(3):
        grade = random.randint(0,100)
        sheet.write(row,col,grade)

workbook.save("abc.xls")